package com.kkd.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;

/**
 * @author 14587
 * @date 2021/1/16 11:01
 */
@SpringBootApplication//启动类
@EnableEurekaClient//表示要注册到eureka
@EnableDiscoveryClient//这是用于团队开发，以便获得client
@EnableCircuitBreaker//添加对熔断的支持
@EnableHystrixDashboard//添加监控
public class DeptProvider_Hytrix_8001 {
    public static void main(String[] args) {
        SpringApplication.run(DeptProvider_Hytrix_8001.class,args);
    }

    //我们需要注册bean然后注册到dashboard
    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");
        return servletRegistrationBean;
    }
}
